package com.yeban.base.day06.homework;

import java.util.Scanner;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/2
 *
 */

//练习1：字符串反转
public class StringTest01 {

    public static String reserveString(String str) {

        char[] arr = str.toCharArray();
        for (int i = 0; i < arr.length/2; i ++) {
            char temp = arr[i];
            arr[i] = arr[arr.length - i - 1];
            arr[arr.length - i - 1] = temp;
        }

        return new String(arr);
    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.print("请输入一个字符串：");
        String str = sc.nextLine();

        System.out.println("反转后的字符串：" + reserveString(str));
    }
}
